package com.wanke.domain.po;


import cn.beepower.eig.msg.MeasureValue;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.wanke.domain.po.msg.CloudMeasureValue;

import java.util.Date;

/**
 * 量测对象
 * @author liuronglei
 */
public class Measurement {
    private Long pointNumber;
    private String dtime;
    private Long rtime;
    private Double val;
    private Integer flag;

    @JsonIgnore
    private Date storeTime;

    public Measurement(MeasureValue measureValue) {
        this.pointNumber= measureValue.getPointId();
        if (measureValue.getIsDiscrete()) {
            this.val = (double) measureValue.getDiscreteValue();
        } else {
            this.val=(double)measureValue.getAnalogValue();
        }
        this.flag=measureValue.getFlag();
        this.rtime= measureValue.getTimestamp();
        this.setStoreTime(new Date());
    }

    public CloudMeasureValue toCloudMeasureValue() {
        return   new CloudMeasureValue(pointNumber, val,0  ,rtime==null?0:rtime);
    }

    public Measurement() {
    }


    public Long getPointNumber() {
        return pointNumber;
    }

    public void setPointNumber(Long pointNumber) {
        this.pointNumber = pointNumber;
    }

    public String getDtime() {
        return dtime;
    }

    public void setDtime(String dtime) {
        this.dtime = dtime;
    }

    public Long getRtime() {
        return rtime;
    }

    public void setRtime(Long rtime) {
        this.rtime = rtime;
    }

    public Double getVal() {
        return val;
    }

    public void setVal(Double val) {
        this.val = val;
    }

    public Integer getFlag() {
        return flag;
    }

    public void setFlag(Integer flag) {
        this.flag = flag;
    }

    public Date getStoreTime() {
        return storeTime;
    }

    public void setStoreTime(Date storeTime) {
        this.storeTime = storeTime;
    }
}
